package com.richapp.launcher.utils;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by wangwei on 2017/4/8.
 */

public class SharePrefenceUtil {
    public static final String SHARE_KEY = "LAUCHER_RICHAPP";
    public static final String SHARE_IP_LOCATION_TOKEN ="KEY_IP_LOCATION" ;
    public static final String SHARE_WHEATHER_TOKEN ="KEY_WHEATHER" ;
    public static final String SHARE_PM25_TOKEN ="KEY_PM25" ;

    public  static final  String SHAPRE_DESCRIBE_BOX = "SHAPRE_DESCRIBE_BOX";

    public static final String SHARE_KEY_LOCATION_DAY ="KEY_LOCATION" ;
    public static final String SHARE_KEY_WEATHER_DAY ="KEY_WEATHER_DAY" ;
    public static final String SHARE_KEY_PM25_DAY ="KEY_PM25_DAY" ;

    public static final String SHARE_TIME_DAY ="SHARE_TIME_DAY" ;

    /**
     * 是否显示 传感的等级
     */
    public static  final  String SHPAE_SHOW_SENCELEL = "SHPAE_SHOW_SENCELEL";

    public static void setStringValue(Context context, String str, String key) {
        SharedPreferences share = context.getSharedPreferences(SHARE_KEY, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = share.edit();
        editor.putString(key, str);
        editor.apply();
    }

    public static String getStringValue(Context context, String key) {
        SharedPreferences share = context.getSharedPreferences(SHARE_KEY, Context.MODE_PRIVATE);
        return share.getString(key, "");
    }

    public static void setBooleanVal(Context context, boolean bool, String key) {
        SharedPreferences share = context.getSharedPreferences(SHARE_KEY, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = share.edit();
        editor.putBoolean(key, bool);
        editor.apply();
    }

    public static boolean getBooleanVal(Context context, String key) {
        SharedPreferences share = context.getSharedPreferences(SHARE_KEY, Context.MODE_PRIVATE);
        return share.getBoolean(key, true);
    }

}
